extends "../calxJS_Hide/calxJS_Hide2.gd"
func _init():
	pass
func _extInit():
	._extInit()
	chaName = "天使王"     
	attCoe.atkRan = 2                 # 攻击距离
	attCoe.maxHp = 4.5                  # 最大生命（每点代表112.5基础数值，取整数，下同）
	attCoe.atk = 4                    # 攻击力（每点代表8.5）
	attCoe.mgiAtk = 7.4                 # 魔法攻击（每点代表13.7）
	attCoe.def = 4                    # 物理防御（每点代表15）
	attCoe.mgiDef = 4                 # 魔法防御（每点代表16.6）
	atkEff = "atk_dao" 
	xb = "王"
	lv = 4   
	addSkillTxt("[王之威慑]大量剑气震慑敌方全体，造成100%王系魔法伤害[CD:10]")
	addSkillTxt("[弥赛亚的救赎]拿起圣剑，穿上金甲，登上王位，每释放一次技能，魔攻在回合内提升30\n上限600,战斗开始20秒后，攻击距离+1，普攻变成九宫格伤害并附带60%法伤")
	addSkillTxt("[天愈剑]使用天愈剑刺向目标单体，造成175%的妖精系魔法伤害\n伤害值的20%用来恢复自身体力[CD:13]")
	addSkillTxt("[color=#FFFF00][天堂之剑][/color]:[color=#FFCC22]世界，应吾所愿！天堂之剑从天而降对目标单体造成240%的王系魔法伤害\n60%概率无视目标50%魔防[CD:18][/color]") 
	addCdSkill("wzws",10)
	addCdSkill("tyj",13)
	addCdSkill("ttzj",18)


func _castCdSkill(id):
	._castCdSkill(id)
	if id == "wzws":
		var chas = getAllChas(1)
		var buff:Buff = hasBuff("jiushu1")
		var eff = sys.newEff("numHit", position, false, 1)
		eff.setText("王之威慑", "#FF0099")
		eff.anim.set_speed_scale(0.2)
		for i in chas:
			typeHurtCha(i,att.mgiAtk*1,Chara.HurtType.MGI,Chara.AtkType.SKILL)
		if buff == null:
			addBuff(jiushu1.new())
		elif buff.att.mgiAtk < 600:
			buff.att.mgiAtk += 30
	if id == "tyj":
		var eff = sys.newEff("numHit", position, false, 1)
		eff.setText("天愈剑", "#FF0099")
		eff.anim.set_speed_scale(0.2)
		typeHurtCha(aiCha,att.mgiAtk*1.75,Chara.HurtType.MGI,Chara.AtkType.SKILL,"妖精")
		plusHp(atkInfo.mgiAtk*0.3)
	if id == "ttzj":
		var eff = sys.newEff("numHit", position, false, 1)
		eff.setText("天堂之剑", "#FF0099")
		eff.anim.set_speed_scale(0.2)
		if sys.rndPer(60):
			addBuff(mochuan.new(1))
		typeHurtCha(aiCha,att.atk*2.4,Chara.HurtType.MGI,Chara.AtkType.SKILL)

var js = 0
var ting = true
func _upS():
	._upS()
	if not ting:return
	js += 1
	if js >= 20 && not self.hasBuff("jiushu2"):
		self.addBuff(jiushu2.new(self))
		ting = false

func _onBattleStart():
	._onBattleStart()
	js = 0
	ting = true

class jiushu2:
	extends Buff
	func _init(cha = null):
		attInit()
		id = "jiushu2"
		var dispelable = true
		att.atkRan += 1
	func _connect():
		masCha.connect("onAtkChara",self,"run")
	var aroundCells = [Vector2(-1,0),Vector2(1,0),Vector2(0,1),Vector2(0,-1),Vector2(1,1),Vector2(-1,-1),Vector2(1,-1),Vector2(-1,1)]
	func run(atkInfo:AtkInfo):
		if atkInfo.atkType == Chara.AtkType.NORMAL:
			masCha.hurtChara(atkInfo.hitCha, masCha.att.mgiAtk*0.7, Chara.HurtType.MGI, Chara.AtkType.EFF)
			for i in aroundCells:
				var cha = masCha.matCha(atkInfo.hitCha.cell+i)
				if cha != null && cha.team != masCha.team:
					masCha.hurtChara(cha, masCha.att.atk, Chara.HurtType.PHY, Chara.AtkType.EFF)
					masCha.hurtChara(cha, masCha.att.mgiAtk*0.6, Chara.HurtType.MGI, Chara.AtkType.EFF)


class jiushu1:
	extends Buff
	func _init():
		attInit()
		var dispelable = true
		id = "jiushu1"	
		att.mgiAtk += 30

class mochuan:
	extends Buff
	func _init(lv = 1):
		attInit()
		var dispelable = true
		id = "mochuan"	
		life = lv 
		att.mgiPenL = 0.5
